package com.nxmu.dao.impl;

import com.nxmu.dao.UserDao;
import com.nxmu.entity.User;
import com.nxmu.enums.Role;

import java.util.List;

public class UserDaoImpl extends BaseDao<User> implements UserDao {

    @Override
    public User login(String userId, String password, Role role) {
        String hql = "FROM User u WHERE u.userId = ? AND u.password = ? ";
        List<User> users = findByHql(hql, userId, password);
        if (users != null && !users.isEmpty()){
            return users.get(0);
        }
        return  null;
    }

    @Override
    public List<User> getByUsername(String username) {
        String hql = "FROM User u WHERE u.username = ?";
        return findByHql(hql, username);
    }


}
